package com.cdu.guoxinan.www.smartcom.controller;

import com.cdu.guoxinan.www.smartcom.aop.Annotation.OperationLog;
import com.cdu.guoxinan.www.smartcom.domian.dto.QueryRoleDTO;
import com.cdu.guoxinan.www.smartcom.domian.pojo.Role;
import com.cdu.guoxinan.www.smartcom.service.RoleService;
import com.cdu.guoxinan.www.smartcom.unit.model.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/role")
@Api(tags = "角色管理")
public class RoleController {
    @Resource
    private RoleService roleService;
    @PostMapping("/add")
    @ApiModelProperty("添加角色")
    @OperationLog(description = "添加角色")
    public R add(Role  role) {
        return roleService.add(role);
    }

    @GetMapping("/query")
    @ApiModelProperty("查询角色")
    public R query(QueryRoleDTO queryRoleDTO) {
        return roleService.query(queryRoleDTO);
    }
    @PostMapping("/delete")
    @ApiModelProperty("删除角色")
    @OperationLog(description = "删除角色")
    public R delete(Integer roleId) {
        return roleService.delete(roleId);
    }
    @PostMapping("/update")
    @ApiModelProperty("修改角色")
    @OperationLog(description = "修改角色")
    public R update(Role role) {
        return roleService.update(role);
    }
    @GetMapping("/list")
    @ApiModelProperty("查询所有角色")
    public R list() {
        return roleService.list();
    }
}
